package com.bitbakery.plugin.cl.lang.psi;

import com.bitbakery.plugin.cl.CLIcons;
import com.bitbakery.plugin.cl.lang.CLElementVisitor;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiSubstitutor;
import com.intellij.psi.scope.PsiScopeProcessor;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public class CLDefmacro extends CLDefun {
    public CLDefmacro(ASTNode node) {
        super(node);
    }

    public boolean processDeclarations(PsiScopeProcessor processor,
                                       PsiSubstitutor substitutor,
                                       PsiElement lastParent,
                                       PsiElement place) {
/*
        if (lastParent != null && lastParent.getParent() == this) {
            final CommonLispParameter[] params = getFormalParameterList().getParameters();
            for (CommonLispParameter param : params) {
                if (!processor.execute(param, substitutor)) return false;
            }
        }
*/

        return processor.execute(this, substitutor);
    }

    public void accept(@NotNull PsiElementVisitor visitor) {
        if (visitor instanceof CLElementVisitor) {
            ((CLElementVisitor) visitor).visitCommonLispMacroDefinition(this);
        } else {
            visitor.visitElement(this);
        }
    }

    public String toString() {
        return "CLDefmacro";
    }

    public Icon getIcon(int flags) {
        return CLIcons.COMMON_LISP_DEFMACRO_NODE;
    }
}
